package com.ybxx.core.web.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class ImageVerifyServlet extends HttpServlet {
	 	 ImageGenerator imageGenerator = new ImageGenerator();   
	     @Override  
	     protected void doPost(HttpServletRequest request,   
	             HttpServletResponse response) throws ServletException, IOException {   
	         doGet(request, response);   
	     }   
	     @Override  
	     protected void doGet(HttpServletRequest request,   
	             HttpServletResponse response) throws ServletException, IOException {   
	         //Servlet输出流   
	         ServletOutputStream out = response.getOutputStream();   
	         String randString = request.getSession(true).getAttribute("randString")==null?"":request.getSession(true).getAttribute("randString").toString();   
	            
	         String ucode = request.getParameter("ucode"); 
	         response.setContentType("text/html;charset=UTF-8"); 
	         if (randString.toLowerCase().equalsIgnoreCase(ucode.toLowerCase())) {   
	            out.println(true);   
	         }   
	         else {   
	             out.println(false);   
	         }   
	         // 关闭输出流   
	         out.close();   
	     }   
	 }  


